<template>
  <div class="login">
    <topnave></topnave>
    <div class="inputbox">
      <van-cell-group inset>
        <!-- 输入手机号，调起手机号键盘 -->
        <van-field v-model="phone" type="tel" label="手机号" />
        <van-field v-model="password" type="password" label="密码" />
      </van-cell-group>
      <van-button
        type="success"
        round="true"
        style="width:3rem;margin: 0.2rem auto; display: inherit;"
        @click="login"
      >登录</van-button>
    </div>
  </div>
</template>
<script>
import { getcellphone, getuserDetail } from '../js/axios'
import {mapState} from 'vuex'
import topnave from "../components/topnav/topnav.vue";



export default {
  components:{
    topnave
  },
  data () {
    return {
      phone: 17688459530,
      password: 'Lin20160828',
    }
  },
  computed:{
    ...mapState(['user'])
  },
  methods: {
    async login () {
      getcellphone(this.phone, this.password).then(res => {
        // console.log(res.data)
        if (res.data.code == 200) {
          this.$store.commit('setUser', {
            islogin: true,
            uid: res.data.account.id

          })
          document.cookie='_ntes_nuid=6f4d09464586b34da297090c90da337f; _ntes_nnid=6f4d09464586b34da297090c90da337f,1630549025175; NMTID=00O0jPsqh9wZ9fEx0zJlhsfZZecacEAAAF-M-hREg; WEVNSM=1.0.0; WNMCID=fugucg.1641548370208.01.0; WM_TID=gTucJABkQ%2B9BFRRBQEdrqA5L6dFjIRM%2B; UM_distinctid=17e66acd3bdbe2-0d2e712a2837c7-3b39580e-1fa400-17e66acd3be14b; __snaker__id=vAGN59wrTGO6xWf4; _9755xjdesxxd_=32; ntes_kaola_ad=1; __root_domain_v=.163.com; _qddaz=QD.988344998487941; _iuqxldmzr_=32; from=bdjj2006t3648; hb_MA-9F44-2FC2BD04228F_source=www.baidu.com; WM_NI=o%2B8q3%2BVc1K7dTR%2BLRdob1P9yy%2BL6u7ewlp%2Biaa38QlOgxFZDt%2F2kfSPpsKR7gER3BGg0rU2ERLONBT8CoZgKxKtHu4Xy47GWIwRFDvXKVvQYVwIHdM0%2F7HE6PF3MLim6OFM%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6ee87c1528cbeadd8d66bf6b08bb6c45f829a9eaff13eaca69c8de84fa5b7aa85e62af0fea7c3b92aadf5f892b22196bdffacb670988ee5add170adbeffb1bc73bbf584d7f83da7a9a491aa63a3bffdd9d4688db9b8a7d950b8f1fe8ce55994b0bdacd13da59b9ed4c14da5f0beb6b14f929481afc160fc9da1bbe641bc95bca9f8409ca7fcd8c65d8ba99ea7c77e9c959a97d45396a987a9e747f4f1f9a9c83e949afdaecf63afea81a7d037e2a3; __remember_me=true; MUSIC_U=9b8b02c6ffe3550eabadb803cac1bbb9decd1f0847b6910d2efba635e49a3432993166e004087dd3d78b6050a17a35e705925a4e6992f61dfe3f0151024f9e31; __csrf=9e2244d1a171f9959cb9b45ae8ca61f6; gdxidpyhxdE=NN5%2B1JWU886wxG%2Fzx7T9DlxCdzrw%5CPq0tzLqM%2FukVI0QRc6tafmcN7gCiPDB2aemfv%2B3TsVw6m%5CUACMttVnsXlSZ%5CrEO1fpNJneDaJym7Nc7gVHVjhpEYtKP7ab8AEH6wEK%2Bp%2B6j2UgQ3MqL3jwi%2BA31ISqz%2BRCUa2O4a5Px0ZQY9Gl%2B%3A1645675488835; JSESSIONID-WYYY=1AWz9%2B486WmogivJZ7K4EjgrQdkpjRcsZnKOAN%2BdcZ60HImStPErHpkfrSSABlYpN2eQdVRQE9srrsmR%2FDvqd%2BJ%5CWzPjj2pK1Yjp64%5Clznp%2BOlkf4t18rF96rB6nCgfc8sFsSHlV01cVAHzXBpTC%2FbtmgKQl8CjDA1EFDJ3k1DzvYnyf%3A1645690018991'
          getuserDetail(res.data.account.id).then(res => {
            // console.log(res)
            this.user.userDetail = res.data
            this.$store.commit('setUser', this.user)
          })
          // localStorage.user=JSON.stringify()
          //获取用户详情
          this.$router.push('/me')
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.login {
  width: 100%;
  height: 100%;
  position: fixed;
  background-image: url("../../public/imgs/loginbgm.jpg");
  z-index: 99;
  .inputbox {
    width: 85%;

    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    border-radius: 0.4rem;
    padding: 0.5rem;
    // height: ;
  }
}
</style>
